import socket
# (1)创建Socket对象
client_socket = socket.socket()
# (2)IP地址和主机端口 ，向服务器端发送连接请求
ip = '127.0.0.1'
port = 8888
client_socket.connect((ip, port))
print('---------与服务器连接建立成功---------')
# (3)发送数据
client_socket.send('Welcome to python world'.encode('utf-8'))
client_socket.close()
print('发送完毕')